package com.adgox.tiantianbiting.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.adgox.tiantianbiting.R;
import com.adgox.tiantianbiting.bean.ProgramDetailBean;
import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by tang on 2019/3/14.
 */

public class ShareDetailAdapter extends RecyclerView.Adapter<ShareDetailAdapter.ViewHolder> {
    private List<ProgramDetailBean> datas;

    public ShareDetailAdapter(List<ProgramDetailBean> datas) {
        this.datas = datas;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_share_detail, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ProgramDetailBean bean = datas.get(position);
        Glide.with(holder.itemView.getContext()).load(bean.getShareImageUrl()).into(holder.ivBook);
        holder.tvBookName.setText(bean.getTitle());
        holder.tvDescribe.setText(bean.getDescribe());
        holder.tvListen.setText(bean.getListenNum()+"");
        holder.tvSeason.setText(bean.getTotalSeason()+"集");
        holder.tvLastPrice.setText(bean.getTotalCount()+"听币");
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        @BindView(R.id.iv_book)
        ImageView ivBook;
        @BindView(R.id.tv_book_name)
        TextView tvBookName;
        @BindView(R.id.tv_describe)
        TextView tvDescribe;
        @BindView(R.id.tv_listen)
        TextView tvListen;
        @BindView(R.id.tv_season)
        TextView tvSeason;
        @BindView(R.id.tv_last_price)
        TextView tvLastPrice;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
